import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const router = new Router({
        routes: [{
                path: '',
                redirect: '/login'
            },
            {
                path: '/login',
                component: () =>
                    import ('@/views/login')
            },
            {
                path: '/common',
                component: () =>
                    import ('@/views/login/common')
            },
            {
                path: '/authority',
                component: () =>
                    import ('@/views/login/authority'),
            },
        ],
        mode: 'history'
    })
    //判断是否登录
    // router.beforeEach((to, from, next) => {
    //   next();
    //   // let user = JSON.parse(localStorage.getItem("user"));
    //   // if (!user && to.path !== '/login') {
    //   //   next({path: '/login'})
    //   // } else {
    //   //   next();
    //   // }
    // })

// router.beforeEach((to, from, next) => {

//     if (to.path === '/login') return next();

//     this.$axios.post(`/user/verify?=`)
//         .then(res => {
//             const postData = res.daga;
//             if (postData.code != 200) {
//                 this.$message.error("请先登录");
//                 return next('/login');
//             }
//             next();
//         })
// })

export default router
